import { 
  Entity, 
  PrimaryGeneratedColumn, 
  Column, 
  CreateDateColumn, 
  UpdateDateColumn,
  DeleteDateColumn,
  Index 
} from 'typeorm';

@Entity({ 
  name: 'ya_system_user_log',
  engine: 'InnoDB',
  comment: '用户日志'
})
export class SystemUserLog {
  @PrimaryGeneratedColumn({
    type: 'int',
    name: 'log_id',
    comment: '日志id'
  })
  logId: number;

  @Column({
    type: 'tinyint',
    width: 1,
    default: 1,
    comment: '日志类型，0登录1操作2退出'
  })
  logType: number;

  @Column({
    type: 'int',
    name: 'user_id',
    default: 0,
    comment: '用户id'
  })
  userId: number;

  @Column({
    type: 'int',
    name: 'menu_id',
    default: 0,
    comment: '菜单id'
  })
  menuId: number;

  @Column({
    type: 'varchar',
    length: 16,
    default: '',
    comment: '请求方式'
  })
  requestMethod: string;

  @Column({
    type: 'varchar',
    length: 255,
    default: '',
    comment: '请求URL'
  })
  requestUrl: string;

  @Column({
    type: 'varchar',
    length: 128,
    default: '',
    comment: '请求IP'
  })
  requestIp: string;

  @Column({
    type: 'varchar',
    length: 127,
    default: '',
    comment: '请求国家'
  })
  requestCountry: string;

  @Column({
    type: 'varchar',
    length: 127,
    default: '',
    comment: '请求省份'
  })
  requestProvince: string;

  @Column({
    type: 'varchar',
    length: 127,
    default: '',
    comment: '请求城市'
  })
  requestCity: string;

  @Column({
    type: 'varchar',
    length: 127,
    default: '',
    comment: '请求区县'
  })
  requestArea: string;

  @Column({
    type: 'varchar',
    length: 255,
    default: '',
    comment: '请求地区'
  })
  requestRegion: string;

  @Column({
    type: 'varchar',
    length: 100,
    default: '',
    comment: '请求ISP'
  })
  requestIsp: string;

  @Column({
    type: 'mediumtext',
    nullable: true,
    comment: '请求参数'
  })
  requestParam: string;

  @Column({
    type: 'varchar',
    length: 11,
    default: '',
    comment: '返回码'
  })
  responseCode: string;

  @Column({
    type: 'varchar',
    length: 255,
    default: '',
    comment: '返回描述'
  })
  responseMsg: string;

  @Column({
    type: 'varchar',
    length: 1024,
    default: '',
    comment: '用户代理'
  })
  userAgent: string;

  @Column({
    type: 'tinyint',
    width: 1,
    default: 0,
    comment: '是否删除，1是0否'
  })
  isDelete: number;

  @Column({
    type: 'int',
    name: 'create_uid',
    default: 0,
    comment: '添加用户id'
  })
  createUid: number;

  @Column({
    type: 'int',
    name: 'update_uid',
    default: 0,
    comment: '修改用户id'
  })
  updateUid: number;

  @Column({
    type: 'int',
    name: 'delete_uid',
    default: 0,
    comment: '删除用户id'
  })
  deleteUid: number;

  @CreateDateColumn({
    name: 'create_time',
    comment: '添加时间'
  })
  createTime: Date;

  @UpdateDateColumn({
    name: 'update_time',
    comment: '修改时间'
  })
  updateTime: Date;

  @DeleteDateColumn({
    name: 'delete_time',
    nullable: true,
    comment: '删除时间'
  })
  deleteTime: Date;
}